﻿
@{
    ViewBag.Title = "首页";
}
<div class="panel panel-default">
    <div class="panel-heading">
        请求参数说明
    </div>
    <div class="panel-body">
        <table class="table table-striped">
            <thead>
                <tr>
                    <td>参数名</td>
                    <td>必选</td>
                    <td>说明</td>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>token</td>
                    <td>是</td>
                    <td>DNSPod Token</td>
                </tr>
                <tr>
                    <td>domain</td>
                    <td>是</td>
                    <td>域名（如：baidu.com）</td>
                </tr>
                <tr>
                    <td>record</td>
                    <td>是</td>
                    <td>记录名，唯一（如：www）</td>
                </tr>
                <tr>
                    <td>ip</td>
                    <td>否</td>
                    <td>DDNS的IP地址，默认不填，根据请求来源IP更新</td>
                </tr>
            </tbody>
        </table>
    </div>
</div>
<hr />
<h3>使用方法</h3>
<div class="panel panel-default">
    <div class="panel-heading">
        CURL
    </div>
    <div class="panel-body">
        <pre>
    curl -k -X POST http://ddns.zwsdk.cn/ddns -d "token=id,token&ip=192.168.1.1&record=www&domain=dnspod.cn"
        </pre>
    </div>
</div>
<div class="panel panel-default">
    <div class="panel-heading">
        Mikrotik（ROS）
    </div>
    <div class="panel-body">
        <pre>
    #DDNS Token
    :local dnspodtoken "id,token"

    #DDNS域名
    :local record "www"
    :local domain "dnspod.cn"

    :global current;

    #获取当前拨号的外网IP
    :local now [/ip address get [find interface="pppoe-out1"] address];

    #判断当前IP与之前的IP是否一致
    :if ($now != $current) do={

        #日志输出改变前后的IP
        :log info "ip address $current changed to $now";
        :set current $now;

        #截取真实IP，去掉子网掩码
        :local ip [:pick $now 0 [:find $now "/"]]
        :log info "IP address string: $ip "

        #拼接请求地址
        :local url "http://ddns.zwsdk.cn/ddns\?token=$dnspodtoken&ip=$ip&record=$record&domain=$domain";
        /tool fetch url=("$url") mode=http keep-result=no
        :log info "URL: $url"

    }
        </pre>
    </div>
</div>
